<!DOCTYPE HTML >

<html>
  <head>
	<meta charset="UTF-8">
    <title>Title</title>
    
<!--	<meta http-equiv="pragma" content="no-cache">-->
<!--	<meta http-equiv="cache-control" content="no-cache">-->
<!--	<meta http-equiv="expires" content="0">-->
<!--	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">-->
<!--	<meta http-equiv="description" content="This is my page">-->
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
<!--	<meta name="viewport" content="width=device-width, initial-scale=1.0">-->

	  <!-- 引入Bootstrap核心文件 -->
	  <link href="css/bootstrap.min.css" rel="stylesheet">

	  <!-- jQuery(Bootstrap的JavaScript插件需要引入jQuery，务必在bootstrap.min.js之前引入) -->
	  <script src="js/jquery.min.js"></script>

	  <!-- 包括所有已编译的JS插件 -->
	  <script src="js/bootstrap.min.js"></script>
	
  </head>
  
  <body>
    <div class="container" style="font-family:微软雅黑;font-size:larger">
    	<div class="page-header">
        <h2 align="center">新闻列表</h2>
    </div>
			
			<div class="col-md-offset-1 col-md-10">
				<form action="/index" class="navbar-form navbar-left" role="search">
					<div class="form-group">
						新闻标题：
						<input type="text" class="form-control" name="title" id="title" value="${title}">
					</div>
					&nbsp;
					<div class="form-group">
						<button type="submit" class="btn btn-default" id="query">查询</button>
					</div>
				</form>
				
				<table class="table table-bordered">
					<thead>
						<tr align="center">
							<td>新闻编号</td>
							<td>新闻标题</td>
							<td>作者</td>
							<td>创建时间</td>
							<td>评论量</td>
							<td>操作</td>
						</tr>
					</thead>
					<#--freemarker标签内的变量不用el表达式-->
					<#--循环列表users，循环变量为u-->
					<#list pageResult.resultList as news>
						<tr>
							<td>${news.newsCode}</td>
							<td>${news.title}</td>
							<td>${news.author}</td>
							<td>${news.createDate}</td>
							<td>${news.commentAccount}</td>
							<td><a href="/showDetail?newsCode=${news.newsCode}">查看新闻</a></td>
						</tr>
					</#list>
				</table>
				
				<div align="center">
					<nav>
						<ul class="pagination">
							<#--<#if pageResult.currentPage == 1>
								<li class="disabled"><span>首页</span></li>
								<li class="disabled"><span aria-hidden="true">&laquo;</span></li>
							<#else>
								<li><a href="/index?pageNo=1">首页</a></li>
								<li><a href="/index?pageNo=${pageResult.currentPage-1}" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
							</#if>
							<li><a href="/index?pageNo=${pageResult.currentPage-1}" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>-->

							<li class="page-item ${(pageResult.currentPage == 1)?string("disabled","")}">
								<a class="page-link" href="/index?pageNo=1" tabindex="-1">首页</a>
								<a class="page-link" href="/index?pageNo=${pageResult.currentPage-1}" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
							</li>
							<#list 1..pageResult.totalPages as i>
								<li class="page-item ${(pageResult.currentPage == i)?string("active","")}">
									<a href="/index?pageNo=${i}">${i}</a>
								</li>
							</#list>
							<li class="page-item ${(pageResult.currentPage == pageResult.totalPages)?string("disabled","")}">
								<a class="page-link" href="/index?pageNo=1" tabindex="-1">末页</a>
								<a class="page-link" href="/index?pageNo=${pageResult.currentPage-1}" aria-label="Previous"><span aria-hidden="true">&raquo;</span></a>
							</li>
							<#--从1循环到pageResult.totalPages-->
							<#--<#list 1..pageResult.totalPages as i>
								<#if pageResult.currentPage == i>
									<li class="disabled"><span>${i}</span></li>
								<#else>
									<li><a href="/index?pageNo=${i}">${i}</a></li>
								</#if>
							</#list>-->
							<#--<#if pageResult.currentPage == pageResult.totalPages>
								<li class="disabled"><span aria-hidden="true">&raquo;</span></li>
								<li class="disabled"><span>末页</span></li>
							<#else>
								<li><a href="/index?pageNo=${pageResult.currentPage+1}" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>
								<li><a href="/index?pageNo=${pageResult.totalPages}">末页</a></li>
							</#if>-->
						</ul>
					</nav>
				</div>
		</div>
	</div>
  </body>
  <script type="text/javascript">
	  $(document).ready(function () {
		  $("#query").click(function(){
			  $.ajax({
				  url:"/news/index",    //请求的url地址
				  dataType:"json",   //返回格式为json
				  async:true,//请求是否异步，默认为异步，这也是ajax重要特性
				  data:{title:$("#title").val()},    //参数值
				  type:"GET",   //请求方式
				  beforeSend:function(){
					  //请求前的处理
				  },
				  success:function(req){
					  //请求成功时处理
				  },
				  complete:function(){
					  //请求完成的处理
				  },
				  error:function(){
					  //请求出错处理
				  }
			  });
		  });
	  })
  </script>
</html>
